package top.baselitch.liteorm;

import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;

public class LiteORM {
    private static LiteORM instance;
    private LiteDBHelper dbHelper;
    private LiteORM(){

    }
    public static LiteORM getInstance(){
        if(instance==null){
            instance = new LiteORM();
        }
        return instance;
    }
    public void init(Context context){
        try {
            ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
            Bundle bundle = applicationInfo.metaData;
            this.dbHelper = new LiteDBHelper(context,bundle.getString("LiteDb"),bundle.getInt("LiteDbVersion"));

        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
    }
    public LiteDBHelper getDbHelper(){
        return dbHelper;
    }
}